<?php
include_once 'protocol_includes.php';

class CheckAuthentication
{
    private $cmd;

    public static function isOk(command $cmd)
    {
        $N = new CheckAuthentication($cmd);
        return $N->isAuthenticated();
    }

    public function __construct(command $cmd)
    {
        $this->cmd = $cmd;
    }

    public function isAuthenticated()
    {
        echo $authStatus;
        $authStatus = ns_dao_user::CheckLoginKey($this->LoginKey());
        switch ($authStatus) {
            case ns_dao_user::$AUTH_FAIL:
                return false;
                break;

            case ns_dao_user::$AUTH_OK:
                return true;
                break;
        }
    }

    public function LoginKey()
    {
        return $this->cmd->GetData('LOGINKEY');
    }
}

?>
